package org.liu.async.kit;

import net.sf.cglib.proxy.Enhancer;
import org.liu.async.interceptors.JobInterceptor;

/**
 * Created by liuj on 2015/12/14.
 */
public class DynamicProxy {


    public static Object getProxy( Class<?> targetClass ,AsyncConfig asyncConfig) {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(targetClass);
        enhancer.setInterfaces(targetClass.getInterfaces());
        enhancer.setCallback(new JobInterceptor(asyncConfig));
        enhancer.setUseCache(true);
        return enhancer.create();
    }

}
